﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TiposComuns.Objectos;
using Servidor.Objectos.Actions;


namespace Servidor.Objectos
{
    [Serializable]
    [System.Xml.Serialization.XmlInclude(typeof(AcceptFriendAction))]
    [System.Xml.Serialization.XmlInclude(typeof(PostAction))]
    [System.Xml.Serialization.XmlInclude(typeof(RemoveFriendAction))]
    [System.Xml.Serialization.XmlInclude(typeof(ReceiveRequestAction))]
    [System.Xml.Serialization.XmlInclude(typeof(RejectRequestAction))]
    [System.Xml.Serialization.XmlInclude(typeof(RequestFriendAction))]
    [System.Xml.Serialization.XmlInclude(typeof(UpdateProfileAction))]
    [System.Xml.Serialization.XmlInclude(typeof(RemoveSearchedAction))]
    [System.Xml.Serialization.XmlInclude(typeof(StoreListSearchedAction))]
    [System.Xml.Serialization.XmlInclude(typeof(StoreSearchedAction))]
    public abstract class Action
    {
        private IDMsg id;

        public Action() { }

        /// <summary>
        /// Execution of the action.
        /// </summary>
        /// <param name="param">User's state</param>
        public abstract void Execute(User user);

        public abstract void RollBack(User user);

        public IDMsg Id
        {
            get { return this.id; }
            set { this.id = value; }
        }

        public void IncID()
        {
            this.id.Inc();
        }

        public void DecID()
        {
            this.id.Dec();
        }

        public Action(IDMsg id)
        {
            this.id = id.Clone();
        }
    }
}
